Skip to content

Conversation

@dimitribouniol
Copy link
Collaborator

I'm still unclear why folks would want to change how challenges are generated, but this change let's them do so with the appropriate warnings in place by adding unsafe setters for changing the challenge returned by the manager. Closes #72

@dimitribouniol dimitribouniol requested a review from 0xTim October 9, 2025 13:25
@dimitribouniol dimitribouniol self-assigned this Oct 9, 2025
public var challenge: [UInt8]
/// The Relying Party should store the challenge temporarily until the authentication flow is complete. When encoding using `Encodable` this is encoded as base64url.
///
/// - Warning: Although the challenge can be changed, doing so is not recommended and can lead to an insecure implementation of the WebAuthn protocol. See ``setUnsafeChallenge(_:)``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just remove this from the API docs, I don't think we need it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in favor of a SeeAlso

/// Unsafely change the challenge that will be delivered to the client.
///
/// - Warning: Although the challenge can be changed, doing so is not recommended and can lead to an insecure implementation of the WebAuthn protocol.
public mutating func setUnsafeChallenge(_ newValue: [UInt8]) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public mutating func setUnsafeChallenge(_ newValue: [UInt8]) {
public mutating func unsafeSetChallenge(_ newValue: [UInt8]) {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed.

/// encoding using `Encodable`, the challenge is base64url encoded.
public let challenge: [UInt8]
///
/// - Warning: Although the challenge can be changed, dooing so is not recommended and can lead to an insecure implementation of the WebAuthn protocol. See ``setUnsafeChallenge(_:)``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll change them right now!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in favor of a SeeAlso.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, should I have kept the warning on unsafeSetChallenge?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah keep the warning on unsafeSetChallenge, we just don't need to include it on the main parameter

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

@0xTim 0xTim enabled auto-merge (squash) November 3, 2025 11:23
@dimitribouniol dimitribouniol merged commit 8e1cb43 into main Nov 3, 2025
24 of 25 checks passed
@dimitribouniol dimitribouniol deleted the dimitri/challenges branch November 3, 2025 11:24
@dimitribouniol dimitribouniol restored the dimitri/challenges branch November 3, 2025 11:24
@dimitribouniol dimitribouniol deleted the dimitri/challenges branch November 3, 2025 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to use custom ChallengeGenerator

3 participants